define(['jquery', 'bootstrap', 'utilback', 'table', 'form', 'myfileinput'], function($, undefined, Utilback, Table, Form, myfileInput) {

	var Controller = {
		config: {
			get_url: '/user/read/detail', // 获取用户详情
		},
		init: function() {
			this.initDic();
            this.initParam();
        },
        initDic:function(){
			// 初始化表格参数配置
		$('[href="#dic"]').on('click',function(){
			Table.api.init({
				singleSelect: true,
				extend: {
					index_url: './json/overhaulMaintenanceProject.json', // 查询列表
					add_url: 'overhaulMaintenanceProjectAdd.html', // 新增页面
					edit_url: 'trackCarRecordfoAdd.html', // 修改页面
					del_url: '/trackCarRecordfo', // 删除
					multi_url: '/trackCarRecordfo',
					guidIn_url: 'driverGuidIn.html', //添加导入页面
					img_url: 'driverInfoAdd.html', //图片的页面
					info_url: 'trackCarRecord.html', //信息的页面
				}
			});
		});
		 $('[href="#dic"]').click();
		var table = $("#dicTable");

			// 初始化表格
			table.bootstrapTable({
				url: $.fn.bootstrapTable.defaults.extend.index_url,
				method: 'get',
				toolbar:'#toolbar1',
				showExport:true,
				columns: [
					[{
							field: 'state',
							checkbox: true,
						},
						{
							field: 'id',
							title: '编号'
						},
						{
							field: 'minrepair',
							title: '项目'
						},
						{
							field: 'couplingDetection',
							title: "类型"
						},
						{
							field: 'axleDetection',
							title: "周期"
						},
						{
							field: 'brakeCheck',
							title: "备注"
				
						},
						{
							field: 'operate',
							title: __('Operate'),
							events: Table.api.events.operate,
							formatter: function(value, row, index) {
								return Table.api.formatter.operate.call(this, value, row, index, table);
							}
						},
					
					]
				]
			});

			// 为表格绑定事件
			Table.api.bindevent(table);
			// 上传组件
			// var oFileInput = new FileInput();
			//     oFileInput.Init("excelFile");

		},
		 initParam:function(){
            var i = 0;
            $('[href="#param"]').on('click',function(){
                Table.api.init({
                    singleSelect:true,
                    extend:{
                        index_url: './json/time.json', // 查询列表
                        del_url: '/overhaulMaintenanceProject', // 删除
                        add_url:'overhaulTimeoutAdd.html',
                        edit_url:'overhaulTimeoutAdd.html',
                        multi_url: '/user',
                        info_url:'',//信息的页面
                    }
                });
                if(i === 0){
                    var paramTable = $("#paramTable");
                    // 初始化表格
                    paramTable.bootstrapTable({
                        toolbar:'#toolbar2',
                        url:$.fn.bootstrapTable.defaults.extend.index_url,
                        method:'get',
                        columns:[
                            [
                                {field:'state',checkbox:true},
                                {field:'id',title:'ID'},
                                {field:'type',title:'业务类型'},
                                {field:'standardTime',title:'标准时间'},
                                {field:'warnTime',title:'提醒时间（天）'},
                                {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: function (value, row, index) {
								return Table.api.formatter.operate.call(this, value, row, index, paramTable)}}
                            ]
                        ]
                    });
                    // 为表格绑定事件
                    Table.api.bindevent(paramTable);
                    i++;
                }
            });
        },

		edit: function() { // 初始化编辑页面
			// 导入的时间绑定
			myfileInput.init.initSubmit('excelFile');
			Form.api.bindevent($("form[role=form]"));
			Form.api.fill($("form[role=form]"), './json/overhaulMaintenanceProject.json', 1);
		},
		update: function() {
			Form.api.bindevent($("form[role=form]"));
			Util.api.ajax({
				type: 'GET',
				url: '/user/read/current'
			}, function(data) {
				$('#edit-form').autofill(data);
			});
		}
	};
	return Controller;

	function changeAgentContent() {
		document.getElementById("inputFileAgent").value = document.getElementById("inputFile").value;
	}
});